package com.template.app.i18n;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Component;

@Component
public class I18N {
    
    private static MessageSource messageSource;
    
    private I18N() {}
    
    public static String getString(String key) {
    	return messageSource.getMessage(key, null, LocaleContextHolder.getLocale());
    }
    
    public static String getString(String key, Object ... args) {
    	return messageSource.getMessage(key, args, LocaleContextHolder.getLocale());
    }

    @Autowired
	public void setMessageSource(MessageSource messageSource) {
    	I18N.messageSource = messageSource;
	}    

}
